import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

const useCounterStore = defineStore(
  'counter',
  () => {
    const count = ref(0)
    const doubleCount = computed(() => count.value * 2)
    function increment() {
      count.value += 1
    }

    return { count, doubleCount, increment }
  },
  {
    persist: {
      // enable: true,
      // storage: localStorage,
      storage: sessionStorage
      // key: 'counter',
      // paths: ['count']
    }
  }
)
// 如果 整个文件 只有一个 export， 推荐使用 export default
export default useCounterStore
